package SV_SQL_DBSOURCE;

import javax.servlet.ServletRequest;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Example {
    public ResultSet getAllPeopleWithSameLastName(ServletRequest req, Connection con, int userId) throws SQLException {
        Statement statement = con.createStatement();
        ResultSet results = statement.executeQuery("SELECT lastName FROM user_data WHERE userid=" + userId);
        String lastName = results.getString("lastName");
        String query = "SELECT * FROM user_data WHERE lastName = '" + lastName + "'";
        return statement.executeQuery(query);
    }
}
